package com.kfm.jdbc.day0406;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class FileUpload {

    public static void main(String[] args) {
        try {
            Socket client = new Socket("10.0.3.198", 8888);

            OutputStream outputStream = client.getOutputStream();
            FileInputStream fis = new FileInputStream("");
            outputStream.write(fis.readAllBytes());
            outputStream.flush();

            client.shutdownOutput();

            fis.close();

            System.out.println("发送成功");

            InputStream inputStream = client.getInputStream();

            byte[] bytes = new byte[1024];
            int read = inputStream.read(bytes);
            System.out.println(new String(bytes, 0, read));

            outputStream.close();
            inputStream.close();
            client.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
